﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _4.CountsElementTestWithMethod
{
    class CountsElementTestWithMethod
    {
        public static int desiredNumber;
        public static int length;
        public static int counter;

        static void CountOfDesiredNumber(int[] myarray1)
        {
            for (int i = 0; i < myarray1.Length; i++)
            {
                if (myarray1[i]==desiredNumber)
                {
                    counter++;
                }
            }
        }
        static void CountOfDesiredNumber(int[] myarray1,int number,int elementOfArray)
        {
            counter=0;
            for (int i = 0; i < myarray1.Length; i++)
            {
                if (myarray1[i] == number)
                {
                    counter++;
                }
            }
            if (number != desiredNumber)
            {
                
                        Console.WriteLine("[{2}]= {0} appears: {1} times", number, counter, elementOfArray);
            }
            else
            {
                return;
            }
            
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Which number:");
            desiredNumber = int.Parse(Console.ReadLine());
            Console.WriteLine("Lenght of array:");
            length = int.Parse(Console.ReadLine());
            int[] myarray;
            myarray = new int[length];
            for (int i = 0; i < length; i++)
            {
                Console.Write("[{0}] = ",i);
                myarray[i] = int.Parse(Console.ReadLine());
            }
            CountOfDesiredNumber(myarray);
            Console.WriteLine("Desired Number: {0} appears: {1} times",desiredNumber,counter);
            Console.WriteLine("OTHERS:");
            for (int i = 0; i < length; i++)
            {
                CountOfDesiredNumber(myarray, myarray[i], i);
            }
        }
    }
}
